package com.sy.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sy.dao.UserDao;
import com.sy.entity.User;
import com.sy.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserDao userDao;
	
	/* 
	 * 检验用户登录业务
	 * 
	 */
	public User checkLogin(String username, String password) {
		
		User user = userDao.findByUsername(username);
		if(user != null && user.getPassword().equals(password)){
		
			return user;
		}
		return null;
	}

	public User findById(int id) {
		return userDao.findById(id);
	}

	public void add(User user) {
		 
		 userDao.add(user);
	}

	public long addAndGetId(User user) {
		 
		return userDao.addAndGetId(user);
	}

	public List<User> list(String username,int page, int size) { 
		return userDao.list(username,page, size);
	}

	public int delete(int id) {
		// TODO Auto-generated method stub
		return userDao.delete(id);
	}

	public int update(User user) {
		// TODO Auto-generated method stub
		return userDao.update(user);
	}

 
	 
}
